package org.example.listnode;

import org.example.Student;
import org.example.zoo.Animal;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Stack;

//链表节点
public class Node {
    //两部分，第一部分是链表上要存的数据
    private int value;
    //第二部分是节点指向的下一个节点
    private Node nextNode;
    //第三部分存该节点的上一个节点
    private Node preNode;
    public Node() {
    }

    public Node(int value) {
        this.value = value;
    }

    public Node(int value, Node nextNode) {
        this.value = value;
        this.nextNode = nextNode;
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    public Node getNextNode() {
        return nextNode;
    }

    public void setNextNode(Node nextNode) {
        this.nextNode = nextNode;
    }

    public Node getPreNode() {
        return preNode;
    }

    public void setPreNode(Node preNode) {
        this.preNode = preNode;
    }

    public static void main(String[] args) {
        String path="/../";
        String strs[] = path.split("/");
        LinkedList<String> list = new LinkedList<>();
        for(int i=0;i<strs.length;i++){
            if(".".equals(strs[i])){
                continue;
            }
            if("..".equals(strs[i])&&!list.isEmpty()){
                list.pop();
                continue;
            }
            if("..".equals(strs[i])){
                continue;
            }
            if("".equals(strs[i])){
                continue;
            }
            list.push(strs[i]);
        }
        if(list.isEmpty()){

        }
        StringBuilder sb = new StringBuilder();
        for(int i=list.size()-1;i>=0;i--){
            String s = list.get(i);
            sb.append("/"+s);
        }
        System.out.println(sb);
    }
}
